/*
# pymoz, Python extension for the Mozilla Toolkit
# Copyright (C) 2012 Malek Hadj-Ali
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


#ifndef pymoz_h_
#define pymoz_h_


#pragma GCC visibility push(default)
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#pragma GCC visibility pop

#include "nsCOMPtr.h"
#include "nsStringAPI.h"

#include "jsapi.h"


#define PY_ENSURE_SUCCESS(res, ret, type, msg) \
    do { \
        nsresult __rv = res; \
        if (NS_FAILED(__rv)) { \
            PyErr_SetString(type, msg); \
            return ret; \
        } \
    } while (0)



/* global utils */

PyObject *
Py_GetGlobals();

PyObject *
PyModule_GetAttrId(const char *modname, _Py_Identifier *attrid);

int
PyModule_SetAttrId(const char *modname, _Py_Identifier *attrid, PyObject *value);

int
PyModule_AddPyObject(PyObject *module, const char *name, PyObject *pyobj);


#endif // pymoz_h_
